package com.kaka.controller;

import com.kaka.javabean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/user")
public class UserController {

    @GetMapping(value = "/t1/{id}",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String select(@PathVariable(value = "id",required = false) Integer id) {
        System.out.println("id = " + id);
        return "查找id为：" + id + "的用户信息";
    }

    @PostMapping(value = "/t1",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public User insert(@RequestBody User user) {
        System.out.println("添加用户：" + user);
        return user;
    }

    @PutMapping(value = "/t1",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public User update(@RequestBody User user) {
        System.out.println("修改用户：" + user);
        return user;
    }

    @DeleteMapping(value = "/t1/{id}",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String delete(@PathVariable(value = "id",required = false) Integer id) {
        System.out.println("删除用户id：" + id);
        return "删除id为：" + id + "的用户信息";
    }
}
